﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace EntityFrameWorkTest.Models.Mapping
{
    class JumpMap : EntityTypeConfiguration<Jump>
    {
        public JumpMap()
        {
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.ToTable("Jumps");
            this.Property(t => t.id).HasColumnName("Id");
            this.Property(t => t.height).HasColumnName("Height");
            this.Property(t => t.diverId).HasColumnName("DiverId");

            this.HasRequired(t => t.diver)
                .WithMany(t => t.jumps)
                .HasForeignKey(t => t.diverId);
        }
    }
}
